$(function() {
    My.init();
});

var My = {
    init: function () {},
        
    modPhoto: function()
    {
        var options = {
            target: '#form_output',
            url: '/cont/?c=my&m=modify',
            dataType: 'json',
            beforeSubmit: My.reqModPhoto,
            success: My.resModPhoto
        };
        
        /*
        $('#regForm').attr('action', '/cont/?c=main&m=add');
        $('#regForm').submit();
        return false;
        */
        
        $('#regForm').ajaxSubmit(options);
    },
    
    reqModPhoto: function(formData, jqForm, options)
    {
        if (!$('#uploads').val()) {
            return false;
        }
        
        Base.spinOn();
        
        return true;
    },
    
    resModPhoto: function(responseText, statusText, xhr, $form)
    {
        Base.spinOff();
        
        if (responseText.code == 200) {
            //alert(Base.msg[200]);
            top.location.reload();
            
        } else {
            alert(Base.msg[201]+' '+responseText.code+' : '+responseText.msg);
        }
        
        return false;
    },
    
    modUserInfo: function()
    {
        var params = 'c=my&m=modUserInfo&'+$('#modUserInfoForm').serialize();
        
        Base.spinOn();
        
        $.ajax({
            type: 'POST',
            url: '/cont/',
            dataType: 'json',
            data: params,
            success:function(data) {
                Base.spinOff();
                if (data.code == 200) {
                    //alert(Base.msg[200]);
                    //window.location.reload();
                    
                } else {
                    alert('잘못 되었습니다. 다시 시도해 주세요. [ code : '+data.code+']');
                }
            }
        });
    }
};